package com.leetcode.LC;

import java.util.HashMap;
import java.util.Map;

public class LC01 {

    static class Solution {
        public int[] twoSum(int[] nums, int target) {
            int[] ints = new int[2];
            int i=0;
            Map<Integer, Integer> map = new HashMap<>();
            for (int num : nums) {
                if(!map.containsKey(target-num)){
                    map.put(num,i);
                }else {
                    ints[0]=map.get(target-num);
                    ints[1]=i;
                }
                i++;
            }
            return ints;
        }
    }

    public static void main(String[] args) {
        Solution solution = new Solution();
        for (int i : solution.twoSum(new int[]{3,2,4}, 6)) {
            System.out.println(i);
        }

    }

}
